# try something like
def index(): return dict(m="hello from test.py")

def hello():
    response.view='test/hello.html'
    response.flash='hahaha~~~'
    return dict(message=T('hello world'),request=request,session=session,response=response)
#    return HTML(BODY(DIV(T('hello world'),_style='color:red; font-size:38px'))).xml()

def itemlink():
    return dict()
    
def recipes():
    records=db().select(db.recipe.ALL,orderby=db.recipe.title)
    return dict(records=SQLTABLE(records))

def show():
    id=request.vars.id
    recipes=db(db.recipe.id==id).select()
    if not len(recipes): redirect(URL(r=request,f='recipes'))
    return dict(recipe=recipes[0])
    
def new_category():
    form=SQLFORM(db.category)
    if form.accepts(request.vars,session):
        redirect(URL(r=request,f='new_recipe'))
    return dict(form=form)

def new_recipe():
    form=SQLFORM(db.recipe,fields=['title','description','category','instructions'])
    if form.accepts(request.vars,session):
        redirect(URL(r=request,f='recipes'))
    return dict(form=form)

def rows():
    id= dbOBJECT.person.insert(name='max')
    query=(dbOBJECT.person.id==id)
    dbOBJECT(query).count()
    dbOBJECT(query).update(name='Max')
    rows = dbOBJECT(query).select(orderby=dbOBJECT.person.name)
    for row in rows:
        print row
